package everydayone.uniquePaths;
/**
 * @date 2020/07/07
 * @author 王光浩
 * @thinking 使用备忘录模式解决
 * @analysis 时间复杂度O（n），空间复杂度O（n）
 */
public class MyMethodTwo {
	public int uniquePaths(int m, int n) {
		if (m <= 0 || n <= 0)
			return -1;
		int[][] helper = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (i == 0 || j == 0) 
					helper[i][j] = 1;
				else
					helper[i][j] = helper[i-1][j] + helper[i][j-1];
			}
		}
		return helper[n-1][m-1];
	}
}
